import { fromLonLat } from "ol/proj";
import { Notify } from "./notify";
/**
 * @description 定位到当前位置
 * @export
 */
export function locateHere() {
  navigator.geolocation.getCurrentPosition(
    (post) => {
      const lat = post.coords.latitude;
      const lon = post.coords.longitude;
      window.map.getView().setCenter(fromLonLat([lon, lat]));
      window.map.getView().setZoom(14);
      Notify.success("定位成功！");
    },
    (error) => {
      Notify.warning("定位失败，无法获取地理位置，请授权！");
    }
  );
}

